# 顶层CMake文件

cmake_minimum_required(VERSION 3.10)

# 设置策略CMP0074为NEW，让CMake使用<PackageName>_ROOT变量
if(POLICY CMP0074)
  cmake_policy(SET CMP0074 NEW)
endif()

project(OrangePi3B_Project VERSION 1.0.0 LANGUAGES CXX)

# 设置C++标准
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_BUILD_TYPE Debug)
# 设置构建类型
if(NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE Release)
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")

# 设置安装目录
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
    set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Installation directory" FORCE)
endif()

# 检测是否在交叉编译模式
if(CMAKE_CROSSCOMPILING)
    message(STATUS "交叉编译模式 - 目标架构: ${CMAKE_SYSTEM_PROCESSOR}")

    set(OpenCV_ROOT "${CMAKE_SOURCE_DIR}/3rdparty/opencv-4.5.4")
    set(OpenCV_DIR "${OpenCV_ROOT}/lib/cmake/opencv4/OpenCVConfig.cmake")
    find_package(OpenCV REQUIRED)

    set(Qt5_ROOT "${CMAKE_SOURCE_DIR}/3rdparty/qt-5.15.3")
    set(Qt5_DIR "${Qt5_ROOT}/lib/cmake/Qt5")
    find_package(Qt5 COMPONENTS Core Gui Widgets REQUIRED)

else()
    message(STATUS "本地编译模式")
    find_package(OpenCV REQUIRED)
    find_package(Qt5 COMPONENTS Core Gui Widgets REQUIRED)
endif()

# # 添加测试程序
# add_subdirectory(src/opencv_test)
# add_subdirectory(src/qt_test)
# add_subdirectory(src/hikvision_test)
# add_subdirectory(src/rknpu2_rga_pyh_test)
add_subdirectory(src/defect_dectect_system)